package cn.com.nes.common.packet;


import cn.com.nes.common.generator.DefaultSequenceNumberGenerator;
import cn.com.nes.common.generator.SequenceNumberGenerator;

import java.io.Serializable;

public abstract class AbstractPacket implements Serializable {

    private final Long sequenceNumber;

    public AbstractPacket(Long sequenceNumber) {
        this.sequenceNumber = sequenceNumber;
    }

    public AbstractPacket(SequenceNumberGenerator generator) {
        this(generator.nextSequenceNumber());
    }

    public AbstractPacket() {
        this(DefaultSequenceNumberGenerator.getInstance());
    }

    public abstract PacketType getType();

    public Long getSequenceNumber() {
        return this.sequenceNumber;
    }
}
